package Greed;

import java.util.Arrays;

//用最少得数量的箭引爆气球
public class MinimumNumberOfArrowsToBurstBalloons {
    public int findMinArrowShots(int[][] points) {

            Arrays.sort(points, (v1, v2) -> Integer.compare(v1[1], v2[1]));

        int right=points[0][1];
        int left=points[0][0];
        int ret=1;
        for (int i = 1; i < points.length; i++) {
            int a=points[i][0];
            int b=points[i][1];
            if(a<=right){
                right=Math.min(right,b);
            }else {
                right=b;
                ret++;
            }
        }
        return ret;
    }
}
